home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-25 | 3.3 KB | 107 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWExtMgr.h
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWEXTMGR_H
- #define FWEXTMGR_H
-
- #include "FWTMap.tpp"
-
- #ifndef FWEXCLIB_H
- #include "FWExcLib.h"
- #endif
-
- #ifndef _ISOSTR_
- #include "ISOStr.h"
- #endif
-
- //========================================================================================
- // Globally Accessible Constants
- //========================================================================================
-
- const FW_Boolean FW_kCacheWhenReleased = TRUE;
- const FW_Boolean FW_kDontCacheWhenReleased = FALSE;
-
- const FW_Boolean FW_kCreateExtension = TRUE;
- const FW_Boolean FW_kDontCreateExtension = FALSE;
-
- //========================================================================================
- // Forward Declarations
- //========================================================================================
-
- class ODExtension;
- class FW_CPart;
- struct FW_SPrivExtension;
-
- typedef ODExtension* (*CreateExtensionFunc)(Environment* ev, FW_CPart* part, const char* name, void* refCon);
-
- //========================================================================================
- // struct FW_SPrivExtension
- //========================================================================================
-
- struct FW_SPrivExtension
- {
- FW_SPrivExtension() :
- fCreateFunction(NULL), fRefCon(NULL), fExtension(NULL), fCacheWhenReleased(FALSE) {}
-
- FW_SPrivExtension(CreateExtensionFunc createFunc, void* refCon, FW_Boolean cacheWhenReleased) :
- fCreateFunction(createFunc),
- fRefCon(refCon),
- fExtension(NULL),
- fCacheWhenReleased(cacheWhenReleased) {}
-
- CreateExtensionFunc fCreateFunction;
- void* fRefCon;
- ODExtension* fExtension;
- FW_Boolean fCacheWhenReleased;
- };
-
- typedef FW_TMap<const char*, FW_SPrivExtension> FW_CPrivNameToExtensionMap;
- typedef FW_TPair<const char*, FW_SPrivExtension> FW_CPrivNameToExtensionPair;
-
- //========================================================================================
- // class FW_CExtensionManager
- //========================================================================================
-
- class FW_CExtensionManager
- {
- public:
- FW_DECLARE_AUTO(FW_CExtensionManager)
-
- public:
-
- ~FW_CExtensionManager();
- FW_CExtensionManager(FW_CPart *part);
-
- void RegisterExtension(Environment* ev,
- const char* name,
- CreateExtensionFunc createFunc,
- void* refCon,
- FW_Boolean cacheWhenReleased);
-
- FW_Boolean HasExtension(Environment* ev, const char* name);
-
- ODExtension* AcquireExtension(Environment* ev, const char* name, FW_Boolean allowCreation);
- // acquire the named extension. If allowCreation is FALSE, the requested
- // extension will be returned only if it exists and has a reference count
- // greater than zero. If allowCreation is TRUE, the extension may be
- // created to satisfy the request.
-
- FW_Boolean ReleaseExtension(Environment* ev, ODExtension* extension);
-
- void PurgeCachedExtensions(Environment* ev);
-
- void AbandonExtensions(Environment* ev);
-
- private:
- FW_CPart* fPart;
- FW_CPrivNameToExtensionMap* fNameToExtensionMap;
- };
-
- #endif
-